<template>
  <!--  <el-tabs type="border-card" @tab-click="handleClick">-->
  <!--    <el-tab-pane label="常用软件" name="type0"-->
  <!--      ><ImageTable :list="list"-->
  <!--    /></el-tab-pane>-->
  <!--    <el-tab-pane label="影音软件" name="type1"-->
  <!--      ><ImageTable :list="list"-->
  <!--    /></el-tab-pane>-->
  <!--    <el-tab-pane label="桌面图标" name="type2"-->
  <!--      ><ImageTable :list="list"-->
  <!--    /></el-tab-pane>-->
  <!--  </el-tabs>-->
  <div>
    <div style="height: 100%;min-height: 100%">
      <div style="width: 1152px;margin: 0 auto;text-align: left;">
        <span
          style="font-size: 48px; display: inline-block;vertical-align: middle;width: 20%"
          @click="toHome"
          >米铺优选</span
        >
        <div
          style="display: inline-block;vertical-align: middle;width: 80%;text-align: center"
        >
          <el-image
            src="/api/image/gg.png"
            style="height: 100%;cursor: pointer"
            fit="fill"
            @click="hrefToTbao"
          />
        </div>
      </div>
      <el-row
        style="width: 1152px;
  margin: 0 auto;padding-bottom: 50px; height: 100%;"
      >
        <el-col :span="8">
          <el-table
            :data="appType0"
            border
            style="width: 100%;"
            @row-click="tableClick"
          >
            <el-table-column label="常用软件">
              <template slot="header">
                <div style="width: 100%;text-align: center">
                  <span style="font-size: 22px;font-weight: bold;"
                    >常用软件</span
                  >
                </div>
              </template>
              <template slot-scope="scope">
                <OrderNumber
                  :id="scope.$index + 1"
                  :okey="scope.row.id"
                ></OrderNumber>
                <div
                  style="margin-left:10px;display:inline-block;vertical-align: middle"
                >
                  <el-image
                    style="width: 50px; height: 50px;"
                    :src="orgin + '/image/' + scope.row.logo"
                    fit="cover"
                  ></el-image>
                </div>
                <div
                  style="padding-left: 14px; display:inline-block;vertical-align: middle;margin-top: -10px"
                >
                  <span>{{ scope.row.name }}</span>
                  <div class="bottom clearfix">
                    <time class="time">{{
                      timestampToTime(scope.row.postdate)
                    }}</time>
                  </div>
                </div>
                <div style="display: inline-block" class="download">
                  <el-link :href="url + '/apk/' + scope.row.apk" type="primary"
                    ><el-button class="el-button--primary" @click.native.stop=""
                      >下载</el-button
                    ></el-link
                  >
                </div>
              </template>
            </el-table-column>
          </el-table></el-col
        >
        <el-col :span="8">
          <el-table
            :data="appType1"
            border
            style="width: 100%;"
            @row-click="tableClick"
          >
            <el-table-column label="影音软件">
              <template slot="header">
                <div style="width: 100%;text-align: center">
                  <span style="font-size: 22px;font-weight: bold;"
                    >影音软件</span
                  >
                </div>
              </template>
              <template slot-scope="scope">
                <OrderNumber
                  :id="scope.$index + 1"
                  :okey="scope.row.id"
                ></OrderNumber>

                <div
                  style="margin-left:10px;display:inline-block;vertical-align: middle"
                >
                  <el-image
                    style="width: 50px; height: 50px;"
                    :src="orgin + '/image/' + scope.row.logo"
                    fit="cover"
                  ></el-image>
                </div>
                <div
                  style="padding-left: 14px; display:inline-block;vertical-align: middle;margin-top: -10px"
                >
                  <span>{{ scope.row.name }}</span>
                  <div class="bottom clearfix">
                    <time class="time">{{
                      timestampToTime(scope.row.postdate)
                    }}</time>
                  </div>
                </div>
                <div style="display: inline-block" class="download">
                  <el-link :href="url + '/apk/' + scope.row.apk" type="primary"
                    ><el-button class="el-button--primary" @click.native.stop=""
                      >下载</el-button
                    ></el-link
                  >
                </div>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
        <el-col :span="8">
          <el-table
            :data="appType2"
            border
            style="width: 100%;"
            @row-click="tableClick"
          >
            <el-table-column label="桌面图标">
              <template slot="header">
                <div style="width: 100%;text-align: center">
                  <span style="font-size: 22px;font-weight: bold;"
                    >桌面图标</span
                  >
                </div>
              </template>
              <template slot-scope="scope">
                <OrderNumber
                  :id="scope.$index + 1"
                  :okey="scope.row.id"
                ></OrderNumber>

                <div
                  style="margin-left:10px;display:inline-block;vertical-align: middle"
                >
                  <el-image
                    style="width: 50px; height: 50px;"
                    :src="orgin + '/image/' + scope.row.logo"
                    fit="cover"
                  ></el-image>
                </div>
                <div
                  style="padding-left: 14px; display:inline-block;vertical-align: middle;margin-top: -10px"
                >
                  <span>{{ scope.row.name }}</span>
                  <div class="bottom clearfix">
                    <time class="time">{{
                      timestampToTime(scope.row.postdate)
                    }}</time>
                  </div>
                </div>
                <div style="display: inline-block" class="download">
                  <el-link :href="url + '/apk/' + scope.row.apk" type="primary"
                    ><el-button class="el-button--primary" @click.native.stop=""
                      >下载</el-button
                    ></el-link
                  >
                </div>
              </template>
            </el-table-column>
          </el-table>
        </el-col>
      </el-row>
    </div>
    <div
      style="width: 100%;height:50px;position:relative;margin-top: -50px;clear:both;"
    >
      <hr color="#EBEEF5" />
      <span>米铺优选·Copyright©2020</span>
    </div>
  </div>
</template>

<script>
//import ImageTable from "@/components/ImageTable";
//import app from "@/store/app";
import router from "@/router";
import OrderNumber from "@/components/OrderNumber";

export default {
  name: "UHome",
  components: { OrderNumber },
  data: function() {
    return {
      url: this.$store.state.orgin
    };
  },
  methods: {
    tableClick(row) {
      console.log(row.id);
      router.push({ name: "ShowApp", params: { data: row } });
    },
    timestampToTime(row) {
      const date = new Date(row); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      const Y = date.getFullYear() + "-";
      const M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      const D = date.getDate() + " ";
      return Y + M + D;
    },
    hrefToTbao() {
      window.location.href = "https://mipuyouxuan.taobao.com/";
    },
    toHome() {
      router.push("/home");
    }
  },
  created() {},
  computed: {
    appType0() {
      return this.$store.getters.getAppType0;
    },
    orgin() {
      return this.$store.state.orgin;
    },
    appType1() {
      return this.$store.getters.getAppType1;
    },
    appType2() {
      return this.$store.getters.getAppType2;
    }
  }
};
</script>
<style scoped>
.download {
  visibility: hidden;
}
.el-table td div:hover .download {
  visibility: visible;
}
</style>
